import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'
import ParentView from '@/components/ParentView';

/**
 * Note: 路由配置项
 *
 * hidden: true                   // 当设置 true 的时候该路由不会再侧边栏出现 如401，login等页面，或者如一些编辑页面/edit/1
 * alwaysShow: true               // 当你一个路由下面的 children 声明的路由大于1个时，自动会变成嵌套的模式--如组件页面
 *                                // 只有一个时，会将那个子路由当做根路由显示在侧边栏--如引导页面
 *                                // 若你想不管路由下面的 children 声明的个数都显示你的根路由
 *                                // 你可以设置 alwaysShow: true，这样它就会忽略之前定义的规则，一直显示根路由
 * redirect: noRedirect           // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
 * name:'router-name'             // 设定路由的名字，一定要填写不然使用<keep-alive>时会出现各种问题
 * meta : {
    noCache: true                // 如果设置为true，则不会被 <keep-alive> 缓存(默认 false)
    title: 'title'               // 设置该路由在侧边栏和面包屑中展示的名字
    icon: 'svg-name'             // 设置该路由的图标，对应路径src/assets/icons/svg
    breadcrumb: false            // 如果设置为false，则不会在breadcrumb面包屑中显示
  }
 */

// 公共路由
export const constantRoutes = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: (resolve) => require(['@/views/redirect'], resolve)
      }
    ]
  },
  {
    path: '/login',
    component: (resolve) => require(['@/views/login'], resolve),
    hidden: true
  },
  {
    path: '/404',
    component: (resolve) => require(['@/views/error/404'], resolve),
    hidden: true
  },
  {
    path: '/401',
    component: (resolve) => require(['@/views/error/401'], resolve),
    hidden: true
  },
  {
    path: '',
    component: Layout,
    redirect: 'index',
    children: [
      {
        path: 'index',
        component: (resolve) => require(['@/views/index'], resolve),
        name: '首页',
        meta: { title: '首页', icon: 'dashboard', noCache: false, affix: true }
      },
    ]
  },
  {
    path: '/designManager',
    component: Layout,
    redirect: '/designManager',
    children: [
      {
        path: '/designManager/drawingDesign/addEditView',
        hidden:true,
        component: (resolve) => require(['@/views/designManager/drawingDesign/addEditView'], resolve),
        name: 'DrawingDesignDetail',
        meta: { title: '图纸设计详情', icon: 'dashboard', noCache: false, affix: false,fatherPath:'/designManager/drawingDesign'  }
      },
    ]
  },
  {
    path: '/budgetManager',
    component: Layout,
    redirect: '/budgetManager',
    children: [
      {
        path: '/budgetManager/budgeting/addEditView',
        hidden:true,
        component: (resolve) => require(['@/views/budgetManager/budgeting/addEditView'], resolve),
        name: 'BudgetingDetail',
        meta: { title: '预算编制详情', icon: 'dashboard', noCache: false, affix: false,fatherPath:'/budgetManager/budgeting'   }
      },
    ]
  },
  {
    path: '/resourceMatching',
    component: Layout,
    redirect: '/budgetManager',
    children: [
      {
        path: '/resourceMatching/contractorMatching/addEditView',
        hidden:true,
        component: (resolve) => require(['@/views/resourceMatching/contractorMatching/addEditView'], resolve),
        name: 'ContractorMatchingDetail',
        meta: { title: '承建商匹配详情', icon: 'dashboard', noCache: false, affix: false,fatherPath:'/resourceMatching/contractorMatching'  }
      },
    ]
  },
  {
    path: '/completeAcceptance',
    component: Layout,
    redirect: '/completeAcceptance',
    children: [
      {
        path: '/completeAcceptance/detail',
        hidden: true,
        component: (resolve) => require(['@/views/acceptanceManage/completeAcceptance/detail'], resolve),
        name: 'completeAcceptanceDetail',
        meta: {title: '竣工验收详情', icon: 'dashboard', noCache: false, affix: false,fatherPath:'/completeAcceptance/index'}
      },
    ]
  },
  {
    path: '/settleCompile',
    component: Layout,
    redirect: '/settleCompile',
    children: [
      {
        path: '/settleCompile/detail',
        hidden: true,
        component: (resolve) => require(['@/views/settleManage/settleCompile/detail'], resolve),
        name: 'settleCompileDetail',
        meta: {title: '结算编制详情', icon: 'dashboard', noCache: false, affix: false,fatherPath:'/settleCompile/index'}
      },
    ]
  },
  {
    path: '/payApply',
    component: Layout,
    redirect: '/payApply',
    children: [
      {
        path: '/payApply/detail',
        hidden: true,
        component: (resolve) => require(['@/views/paymentManage/payApply/detail'], resolve),
        name: 'payApplyDetail',
        meta: {title: '付款申请详情', icon: 'dashboard', noCache: false, affix: false,fatherPath:'/payApply/index'}
      }
    ]
  },
  {
    path: '/userDistribute',
    component: Layout,
    redirect: '/userDistribute',
    children: [
      {
        path: '/userDistribute/detail',
        hidden: true,
        component: (resolve) => require(['@/views/systemManager/userDistribute/detail'], resolve),
        name: 'userDistributeDetail',
        meta: {title: '人员分配详情', icon: 'dashboard', noCache: false, affix: false,fatherPath:'/userDistribute/index'}
      }
    ]
  },
  {
    path: '/pigFarmDetails',
    component: Layout,
    redirect: '/pigFarmDetails',
    children: [
      {
        path: '/pigFarm/pigFarmDetails',
        hidden:true,
        component: (resolve) => require(['@/views/pigFarm/pigFarmInfo/details'], resolve),
        name: 'PigFarmDetails',
        meta: { title: '猪场详情', icon: 'dashboard', noCache: false, affix: false ,fatherPath:'/pigFarm/pigFarm'} // fatherPath 标注父级路径 用于菜单高亮
      },
    ]
  },

  {
    path: '/initiationDetails',
    component: Layout,
    redirect: '/initiationDetails',
    children: [
      {
        path: '/projectManagement/initiationDetails',
        hidden: true,
        component: (resolve) => require(['@/views/projectManagement/initiation/details'], resolve),
        name: 'InitiationDetails',
        meta: {
          title: '立项详情',
          icon: 'dashboard',
          noCache: false,
          affix: false,
          fatherPath: '/projectManagement/initiation'
        } // fatherPath 标注父级路径 用于菜单高亮
      },
    ]
  },

  {
    path: '/initiationDetails',
    component: Layout,
    redirect: '/initiationDetails',
    children: [
      {
        path: '/contractManagement/technicalDetails',
        hidden:true,
        component: (resolve) => require(['@/views/contractManagement/technical/details'], resolve),
        name: 'technicalDetails',
        meta: { title: '技改合同详情', icon: 'dashboard', noCache: false, affix: false ,fatherPath:'/contractManagement/technical'} // fatherPath 标注父级路径 用于菜单高亮
      },
    ]
  },

  {
    path: '/constructionPlanDetails',
    component: Layout,
    redirect: '/constructionPlanDetails',
    children: [
      {
        path: '/progressManagement/constructionPlanDetails',
        hidden:true,
        component: (resolve) => require(['@/views/progressManagement/constructionPlan/details'], resolve),
        name: 'ConstructionPlanDetails',
        meta: { title: '施工计划详情', icon: 'dashboard', noCache: false, affix: false ,fatherPath:'/progressManagement/constructionPlan'} // fatherPath 标注父级路径 用于菜单高亮
      },
    ]
  },

  {
    path: '/feedbackDetails',
    component: Layout,
    redirect: '/feedbackDetails',
    children: [
      {
        path: '/progressManagement/feedbackDetails',
        hidden:true,
        component: (resolve) => require(['@/views/progressManagement/feedback/details'], resolve),
        name: 'feedbackDetails',
        meta: { title: '进度查看', icon: 'dashboard', noCache: false, affix: false ,fatherPath:'/progressManagement/feedback'} // fatherPath 标注父级路径 用于菜单高亮
      },
    ]
  },
  {
    path: '/proFeedback',
    component: Layout,
    redirect: '/proFeedback',
    children: [
      {
        path: '/progressManagement/proFeedback',
        hidden:true,
        component: (resolve) => require(['@/views/progressManagement/feedback/proFeedback'], resolve),
        name: 'proFeedback',
        meta: { title: '进度反馈', icon: 'dashboard', noCache: false, affix: false ,fatherPath:'/progressManagement/feedback'} // fatherPath 标注父级路径 用于菜单高亮
      },
    ]
  },
  {
    path: '/feedbackLog',
    component: Layout,
    redirect: '/feedbackLog',
    children: [
      {
        path: '/progressManagement/feedbackLog',
        hidden:true,
        component: (resolve) => require(['@/views/progressManagement/feedback/feedbackLog'], resolve),
        name: 'feedbackLog',
        meta: { title: '进度反馈记录', icon: 'dashboard', noCache: false, affix: false ,fatherPath:'/progressManagement/feedback'} // fatherPath 标注父级路径 用于菜单高亮
      },
    ]
  },

  {
    path: '/proQuality',
    component: Layout,
    redirect: '/proQuality',
    children: [
      {
        path: '/progressManagement/proQuality',
        hidden:true,
        component: (resolve) => require(['@/views/progressManagement/feedback/proQuality'], resolve),
        name: 'proQuality',
        meta: { title: '质量验收', icon: 'dashboard', noCache: false, affix: false ,fatherPath:'/progressManagement/feedback'} // fatherPath 标注父级路径 用于菜单高亮
      },
    ]
  },
  {
    path: '/qualityLog',
    component: Layout,
    redirect: '/qualityLog',
    children: [
      {
        path: '/progressManagement/qualityLog',
        hidden:true,
        component: (resolve) => require(['@/views/progressManagement/feedback/qualityLog'], resolve),
        name: 'qualityLog',
        meta: { title: '质量验收记录', icon: 'dashboard', noCache: false, affix: false ,fatherPath:'/progressManagement/feedback'} // fatherPath 标注父级路径 用于菜单高亮
      },
    ]
  },
  {
    path: '',
    component: Layout,
    redirect: 'index',
    children: [
      // 采购计划 - 详情
      {
        path: '/designManager/procurementPlan/detail',
        component: (resolve) => require(['@/views/designManager/procurementPlan/addEditView'], resolve),
        hidden:true,
        name: 'DesignManagerProcurementPlanDetail',
        meta: { title: '采购计划详情', icon: 'dashboard', noCache: false, affix: false,fatherPath:'/designManager/designManagerProcurementPlan' }
      },
    ]
  }
]

export default new Router({
  mode: 'history', // 去掉url中的#
  base: (process.env.NODE_ENV === "production" || process.env.NODE_ENV === "test")?'/zlg/':'',
  scrollBehavior: () => ({y: 0}),
  routes: constantRoutes
})
